using Aurora.TaskScheduler.Abstractions;
using Aurora.TaskScheduler.Abstractions.Attributes;
using Aurora.TaskScheduler.Abstractions.BaseModel;
using Aurora.TaskScheduler.Abstractions.SchedulerAttributes;
using Quartz;

namespace Gateway.UI.Api.TaskJobs;

/// <summary>
/// 
/// </summary>
[DisallowConcurrentExecution]
//[Cron("0/10 * * * * ?", "每10秒执行一次", description: "Gateway-UI-API,此方法用于测试使用")]
[Cron("0 0 0 * * ?", "每天0点执行一次", description: "Gateway-UI-API,此方法用于测试使用")]
[TaskJobLock]
public class MyTestJob : ITaskJob<string>
{
    private readonly ILogger<MyTestJob> _logger;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="logger"></param>
    public MyTestJob(ILogger<MyTestJob> logger)
    {
        _logger = logger;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="parameter"></param>
    /// <returns></returns>
    public Task<JobResult> ExecuteAsync(string parameter)
    {
        _logger.LogInformation("当前时间：{S},MyTestJob 执行了", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
        return Task.FromResult(new JobResult()
        {
            Success = true,
            Message = "MyTestJob执行成功了"
        });
    }
}